package com.ayoka.parenting.ui.meditation.more;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.ayoka.parenting.R;
import com.ayoka.parenting.adapter.MeditationMoreMultiAdapter;
import com.ayoka.parenting.bean.MeditationMoreMultiEntity;
import com.ayoka.parenting.databinding.ActivityMeditationMoreBinding;
import com.ayoka.parenting.mvp.MVPBaseRecyclerViewActivity;
import com.ayoka.parenting.ui.meditation.detail.MeditationDetailActivity;
import com.jincp.common.brvah.BaseQuickAdapter;
import com.jincp.common.brvah.BaseViewHolder;
import com.jincp.common.model.ToolBarOptions;

import android.support.annotation.NonNull;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;

import java.util.List;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: MeditationMoreActivity.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class MeditationMoreActivity extends MVPBaseRecyclerViewActivity<MeditationMoreMultiEntity, ActivityMeditationMoreBinding, MeditationMoreContract.View, MeditationMorePresenter> implements MeditationMoreContract.View {

    public static void start(Activity activity) {
        Intent intent = new Intent(activity, MeditationMoreActivity.class);
        activity.startActivity(intent);
    }

    @Override
    protected int getContentLayout() {
        return R.layout.activity_meditation_more;
    }

    @Override
    protected SwipeRefreshLayout getRefreshLayout() {
        return mDataBinding.swipeRefresh;
    }

    @Override
    protected RecyclerView getRecyclerView() {
        return mDataBinding.recyclerView;
    }

    @NonNull
    @Override
    protected BaseQuickAdapter<MeditationMoreMultiEntity, BaseViewHolder> getAdapter() {
        MeditationMoreMultiAdapter adapter = new MeditationMoreMultiAdapter();
        adapter.setMeditationMoreContractView(this);
        return adapter;
    }

    @Override
    protected RecyclerView.ItemDecoration getRecycleDivider() {
        return null;
    }

    @Override
    protected boolean getLoadEnable() {
        return false;
    }

    @Override
    protected void getData(boolean isShowWaitDialog) {
        if (mPresenter != null) {
            mPresenter.getMeditationMoreListData(isShowWaitDialog);
        }
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        ToolBarOptions options = new ToolBarOptions();
        options.backgroundResource = 0;
        options.navigateId = R.mipmap.icon_back_white;
        setCustomToolBar(mDataBinding.customToolbar.toolbar, options);

        getData(true);
    }

    @Override
    protected MeditationMorePresenter getPresenter() {
        return new MeditationMorePresenter();
    }

    @Override
    public void configMeditationMoreListData(String lastMeditationId, List<MeditationMoreMultiEntity> listData) {
        ((MeditationMoreMultiAdapter)adapter).setLastMeditationId(lastMeditationId);
        setLoadMoreLayout(listData);
    }

    @Override
    public void goToMeditationDetail(String meditationId, String title, int mediaType) {
        MeditationDetailActivity.start(this, meditationId, title, mediaType);
    }
}
